﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;

using EHTSaleManager.Code;
using EHTSaleManager.Code.BLL;
using EHTSaleManager.Code.Utility;
using EHTSaleManager.Code.Entity;

namespace EHTSaleManager.UIAdmin
{
    public partial class AdminNews : System.Web.UI.Page
    {
        private Int32 pageIndex = 1;
        private Int32 pageSize = 5;
        private Int32 totalRecord;
       
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                pageIndex = Int32.Parse(Request.QueryString["PageIndex"].ToString());
            }
            catch (Exception)
            {
                pageIndex = 1;
            }

            pageSize = this.PaggingControl1.PageSize;

            DataSet dsNews = NewsProvider.GetNews();           

            if (!Page.IsPostBack)
            {
                DataSet dsNewsPaging = NewsProvider.GetNewsWithPaging(pageIndex, pageSize, out totalRecord);
                this.rpNews.DataSource = dsNewsPaging;
                this.rpNews.DataBind();

                this.PaggingControl1.PageURL = "AdminNews.aspx";
                this.PaggingControl1.TotalRecord = totalRecord;
                this.PaggingControl1.PagingSize = pageSize;
            }
        }

        protected void btnAddNews_Click(object sender, EventArgs e)
        {
            Response.Redirect("AdminAddnews.aspx");
        }


       
    }
}